package jee.boot.module.oauth2.config;

import jee.boot.module.oauth2.auth.CustomUserDetailHandler;
import jee.boot.module.oauth2.auth.DefaultAccountValidator;
import jee.boot.module.oauth2.auth.verification.AccountValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * 认证中心默认的接口配置类,可以通过覆盖这些类来实现自定义的功能
 */
@Configuration
public class DefaultBeanConfig {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    /**
     * 配置默认的查询登录账户接口实现类
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(UserDetailHandler.class)
    public UserDetailHandler userDetailHandler(){
        CustomUserDetailHandler handler= new CustomUserDetailHandler(redisTemplate);
        return handler;
    }
    /**
     * 配置默认的验证账户接口实现类
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(AccountValidator.class)
    public AccountValidator accountValidator(){
        DefaultAccountValidator validator= new DefaultAccountValidator(redisTemplate);
        return validator;
    }

}
